package com.zhitong.money.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResponse {
    private boolean isok;   //请求是否处理成功
    private int code;          //请求响应状态码（200成功、400访问不到页面、500系统错误）
    private String message;  //请求结果描述信息
    private Object data;  //请求结果数据

    public static AjaxResponse success() {
        AjaxResponse resultBean = new AjaxResponse();
        resultBean.setIsok(true);
        resultBean.setCode(200);
        resultBean.setMessage("success");
        return resultBean;
    }
    public static AjaxResponse success(String message) {
        AjaxResponse resultBean = new AjaxResponse();
        resultBean.setIsok(true);
        resultBean.setCode(200);
        resultBean.setMessage(message);
        return resultBean;
    }

    public static AjaxResponse success(Object data) {
        AjaxResponse resultBean = new AjaxResponse();
        resultBean.setIsok(true);
        resultBean.setCode(200);
        resultBean.setMessage("请求成功!");
        resultBean.setData(data);
        return resultBean;
    }

    public static AjaxResponse fail(String message){
        AjaxResponse fail=new AjaxResponse();
        fail.setIsok(false);
        fail.setCode(500);
        fail.setMessage(message);
        return fail;
    }

    public static AjaxResponse aFail(String message){
        AjaxResponse fail=new AjaxResponse();
        fail.setIsok(false);
        fail.setCode(300);
        fail.setMessage(message);
        return fail;
    }
}
